dean.edwards.name/weblog/2006/12/packer-php/

A Perfect Port of Packer to PHP

And Peter Piper picked a peck of pickled peppers.;-)

Another port of packer. This time a PHP version by Nicolas Martin:

http://joliclic.free.fr/php/javascript-packer/en/

So far a version of packer exists in the following languages:

The download page contains links to all of the above versions.

There is also this web service thing to try. And this Rhino port might be interesting to some.

Comments (21)

Leave a comment

Good stuff. Just FYI, in a pinch, Troels Jakobsen’s Bookmarklet Builder does a bang-up job of “unpacking” minimized JS pretty well, though it’s not as reliable for minimization.

  • Comment by: Steve Clay
  • Posted:

Looking forward to v3.0. Many people pass js files through custom_rhino before using packer. rhino makes JavaScript code more well formed and ensures that the packed code works. rhino already shortens variable and argument names. Maybe the new version of packer can take advantages of custom_rhino.

  • Comment by: Arrix
  • Posted:

What a coincidence! I just did a same port of the packer in PHP a few weeks ago.

prototype.js don’t work after be packed.

Someone find a way to pack it ?

  • Comment by: Nao
  • Posted:

Nao, you have to ensure semi-colons are present in a lot of areas. I usually visually scan it look for areas to add them, then use Firebug to debug and figure out where the ones I missed are.

no port, but apatana integration of packer: http://pfirsichmelba.de/d.edwards_packer2aptana.zip

@alerxander – thanks for the aptana plugin! I’ve added it to the download page.

  • Comment by: -dean
  • Posted:

Nao, here is another javascript compressor. It compresses several kB better and seems to compress prototype.js ok without any changes made to it. No javascript errors popup after it is compressed. http://www.fanskap.se/crunch

  • Comment by: Rocket
  • Posted:

The above compressor tool has been updated and moved to a new adress: http://www.bananascript.com/

  • Comment by: wildcard
  • Posted:

Hi all-

I made a version of the above script for php4.

[…] A la base disponible en javascript sur le site de Dean Edwards, qui, on peut le dire est l’inspirateur du framework Prototype, cet outil a été developpé en plusieurs autre languages: .NET, python, Perl et meme en Ruby. bizarrement, aussi en WSH (une sorte de javascript en ligne de commande pour window) […]

@Mark – Thanks for the PHP4 conversion. I’ll add it to the download page later.

  • Comment by: -dean
  • Posted:

Verry good job, I “had” lot of big js files. Thank you for this stuff !

Both PHP versions suffer from an old bug: if you have INSIDE a string something that starts with a $, that will be trimmed like if that were a variable.

Ex: var $var = “$this should not be changed!!”;

After compression: v = “t should not be changed!!”;

I think i reported this to Dean a long time ago, and the js version works as intended. I don´t know why the php version doesn´t, since i can see the regular expressions used to protect the strings…

We attempted to implement this PHP JS packer into a product we are building. While the packer works perfectly in our development systems, the second we pushed it into production it totally choked. Be advised that if you plan to use this in a high traffic environment, you would be wise to stress test it before exposing it to high volumes of on-the-fly packing.

  • Comment by: JoeSchmoe
  • Posted:

[…] Further reading: On a quest for ultimate website performance Yahoo! Developer Faster Page Loads – Bundle Your CSS and Javascript CSS shorthand Web Site Optimization PHP Packer Clean CSS Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages. […]

Please give me some directions how to install Obfuscator in Aptana… Do I have to implement it as a Script?

  • Comment by: thehellion
  • Posted:

[…] este post comparo a Closure con las herramientas de compresión mas conocidas, YUI, Packer de Dean Edward y Shrinksafe the Dojo compressor comprimiendo tres importantes frameworks para […]

[…] http://dean.edwards.name/weblog/2006/12/packer-php/ […]

  • Pingback by: Anonymous
  • Posted:

is this pkg/script still pertinent @ PHP 5.3x / 5.4? tia,

  • Comment by: Greg
  • Posted:

He gives every thing to the world for free, even the About script, so people can use or port it to several languages. I would nominate Dean Edward for the next Nobel Prize, in caterogy: Peace

  • Comment by: Nguyen from vietnam
  • Posted:

Comments are closed.